import { BaseCommand } from "./BaseCommand";
import { API_EVENT, COMMAND_STATUS } from "@/FrontProcessing/interface";
/**
 * Cmd_Freebody
 * @description Free Body
 */
export class Cmd_Freebody_Leave extends BaseCommand {
  event = API_EVENT.FREEBODY_LEAVE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_leave(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Enter extends BaseCommand {
  event = API_EVENT.FREEBODY_ENTER;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_enter({...this.params})
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Read_File extends BaseCommand {
  event = API_EVENT.FREEBODY_READ_FILE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_read_file({...this.params})
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Sets extends BaseCommand {
  event = API_EVENT.FREEBODY_SETS;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_sets()
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Update_Entities extends BaseCommand {
  event = API_EVENT.FREEBODY_UPDATE_ENTITIES;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_update_entities(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Find_Nodes extends BaseCommand {
  event = API_EVENT.FREEBODY_FIND_NODES;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_find_nodes(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Apply extends BaseCommand {
  event = API_EVENT.FREEBODY_APPLY;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_apply(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Freebody_Table_Data extends BaseCommand {
  event = API_EVENT.FREEBODY_TABLE_DATA;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .freebody_table_data(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch(err => reject(err));
    });
  }

  undo(): boolean {
    return false;
  }
}
